package com.esiag.pdsteam.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;



@Entity
@Table(name="INFORMATION")
public class Information implements Serializable{
	
	public Information() {
		// TODO Auto-generated constructor stub
	}
	
	
	public Information(Integer id, String description) {
		super();
		this.id = id;
		this.description = description;
	}


	@Id 
	@GeneratedValue
	@Column(name="IDINFORMATION")
	private Integer id;
	
	
	@Column(name="DESCRIPTION")
	private String description;
	
	
	
	@ManyToMany(fetch=FetchType.EAGER)
	@JoinTable(name="INFORMATIONASSOC", 
	joinColumns = @JoinColumn(name="IDINFORMATION"), 
	inverseJoinColumns = @JoinColumn(name="IDTARGET")) 
	private List<Information> sourceInformation;

	@ManyToMany(mappedBy="sourceInformation")
	private List<Information> targetInformation;
	
	
	
	
	@JoinColumn(name = "IDTYPECOMPLEXINFO", referencedColumnName = "IDTYPECOMPLEXINFO")
	@ManyToOne
	private TypeComlexInfo typeComlexInfo;
	
	@JoinColumn(name = "IDACTION", referencedColumnName = "IDACTION")
	@ManyToOne
	private Action action;

	public Information(Integer id, String description,
			TypeComlexInfo typeComlexInfo, Action action) {
		super();
		this.id = id;
		this.description = description;
		this.typeComlexInfo = typeComlexInfo;
		this.action = action;
	}


	public Action getAction() {
		return action;
	}


	public void setAction(Action action) {
		this.action = action;
	}


	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public List<Information> getSourceInformation() {
		return sourceInformation;
	}

	public void setSourceInformation(List<Information> sourceInformation) {
		this.sourceInformation = sourceInformation;
	}



	public List<Information> getTargetInformation() {
		return targetInformation;
	}

	public void setTargetInformation(List<Information> targetInformation) {
		this.targetInformation = targetInformation;
	}

	public TypeComlexInfo getTypeComlexInfo() {
		return typeComlexInfo;
	}

	public void setTypeComlexInfo(TypeComlexInfo typeComlexInfo) {
		this.typeComlexInfo = typeComlexInfo;
	}

	public Information(String description) {
		super();
		this.description = description;
	}


	@Override
	public String toString() {
		return "Information [id=" + id + ", description=" + description
				+ ", typeComlexInfo=" + typeComlexInfo + "]";
	}
	
	

}
